@SpringBootTest
class ConsumerMapperTest {

    @Autowired
    private ConsumerMapper consumerMapper;

    /**
     * 用户注册
     */
    @Test
    void ConsumerMapperAddUserTest1() {
        //组建要注册的用户
        Consumer consumer = new Consumer();
        consumer.setUsername("lisi");
        consumer.setSex((byte)1);
        consumer.setPhoneNum("17765434567");
        consumer.setIntroduction("爱好和平");
        consumer.setEmail("rrr@qq.com");
        consumer.setBirth(new Date());
        consumer.setPassword("123456");
        consumer.setLocation("北京");
        //MD5加密
        String password = DigestUtils.md5DigestAsHex((Constants.SALT + consumer.getPassword()).getBytes(StandardCharsets.UTF_8));
        consumer.setPassword(password);
        //都用用
        if (StringUtils.isBlank(consumer.getPhoneNum())) {
            consumer.setPhoneNum(null);
        }
        if ("".equals(consumer.getEmail())) {
            consumer.setEmail(null);
        }
        consumer.setAvator("img/avatorImages/user.jpg");
        if (consumerMapper.insert(consumer) > 0) {
            System.out.println("注册成功");
        } else {
            System.out.println("注册失败");
        }
    }
}
